<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/8
 * Time: 10:43
 */

namespace app\modules\admin\models;
use yii\db\ActiveRecord;

class Sites extends ActiveRecord
{
    public $is_open;
    public $site_title;
    public static function tableName()
    {
        return 'sites';
    }

    public function rules()
    {
        return [
          [['is_open', 'title'], 'required']
        ];
    }

    public function attributeLabels()
    {
        return [
            'is_open' => '站点开关',
            'site_title' => '站点标题'
        ];
    }
    public function extraFields(){
        $datas = self::find()->asArray()->all();
        $data = [];
        foreach ($datas as $v) {
            $data[$v['option_key']] = $v['option_value'];
        }
        return [
            $data
        ];
    }
}